//
// Created by LiuYou on 2021/8/19.
//

#ifndef HIGHPERFORMANCELINUXSERVERPROGRAMMING_LINUX2_CGI_HPP
#define HIGHPERFORMANCELINUXSERVERPROGRAMMING_LINUX2_CGI_HPP


#include <netinet/in.h>

class CGIConnect {
public:
    /** 初始化客户连接, 清空读缓冲区。*/
    void init(int epollFd, int sockFd, const sockaddr_in& clientAddress);

    void process();

public:
    CGIConnect();

    ~CGIConnect();

private:
    /** 读缓冲区的大小。*/
    static const int BUFFER_SIZE = 1024;

    // Non-const static data member must be initialized out of line.
    // 非常量静态数据成员必须在行外初始化。
//    static int epollFd = -1;

    // 注意: 而且不过不是模板的话必须在与这个头文件对应的源文件中定义！！！！
    static int epollFd;

    int sockFd;

    sockaddr_in address;

    char buf[BUFFER_SIZE];

    /** 标记读缓冲中已经读取的客户数据的最后一个字节的下一个位置。*/
    int readIdx;

};


#endif //HIGHPERFORMANCELINUXSERVERPROGRAMMING_LINUX2_CGI_HPP
